<?php
// Manage genre list
class GenreList
{
	/* Public variables available in genre_list.tpl Smarty template */
	public $mGenres;
	public $mSelectedGenre = 0;
	
	public function __contruct()
	{
        if(!isset($_GET['MerchandiseId']))
        {                                                 
            if (isset($_GET['GenreId']))
                $this->mSelectedGenre = (int)$_GET['GenreId'];
        }    
        else
        {     
            $continue_shopping = Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
            if (array_key_exists('GenreId', $continue_shopping))
                $this->mSelectedDepartment = (int)$continue_shopping['GenreId'];
            else
                trigger_error('GenreId not set');
                
            if (array_key_exists('GenreId', $continue_shopping))
                $this->mSelectedCategory = (int)$continue_shopping['GenreId'];
        }                                             
	}
	
	public function init()
	{
		$this->mGenres = Catalog::GetAllGenres();
		
		for ($i = 0;$i < count($this->mGenres);$i++)
			$this->mGenres[$i]['link_to_genre'] = Link::ToGenre($this->mGenres[$i]['genre_id']);
	}
}
?>